import tkinter as tk
from tkinter import messagebox

# 创建主窗口
root = tk.Tk()
root.title("用户登录")

# 创建用户名标签和输入框
ulabel = tk.Label(root, text="用户名:")
ulabel.grid(row=0, column=0)
uentry = tk.Entry(root)
uentry.grid(row=0, column=1)

# 创建密码标签和输入框
plabel = tk.Label(root, text="密码:")
plabel.grid(row=1, column=0)
pentry = tk.Entry(root, show="*")
pentry.grid(row=1, column=1)

# 创建记住我单选按钮
rbvar = tk.BooleanVar()
rdme = tk.Checkbutton(root, text="记住我", variable=rbvar)
rdme.grid(row=2, column=0, columnspan=2)

# 创建登录按钮
def login():
    name = uentry.get()
    psword = pentry.get()
    if name == "admin" and psword == "123456":
        messagebox.showinfo("登录成功", "欢迎您，管理员!")
    else:
        messagebox.showerror("登录失败", "用户名或密码错误!")

loginbutton = tk.Button(root, text="登录", command=login)
loginbutton.grid(row=3, column=0, columnspan=2)

# 启动主循环
root.mainloop()
